package com.common.utils;

import com.common.GlobalPara;

public class IdUtil {
	//产生id
	public static String getId(){
		if(GlobalPara.snowflake == null){
			throw new RuntimeException("Please Init snowflake first!");
		}
		return String.valueOf(GlobalPara.snowflake.nextId());
	}
	//格式化id,返回string格式
	//时间+sequence+datacenter+workerid
	public static String formatId(long id) {
		return GlobalPara.snowflake.formatId(id);
	}
	
	//返回时间 sequence datacenterid workerid的数组
	public static long[] parseId(long id) {
		return GlobalPara.snowflake.parseId(id);
	}
}
